package com.heng.application.mocklocation

import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.heng.application.R
import com.heng.mapbundle.MockLocation
/**
 * @Author    : zhangheng227
 * date       : 2025/5/12
 */
class BusinessActivity : AppCompatActivity() {

    private var tv_longitude: TextView? = null
    private var tv_latitude: TextView? = null
    private var btn_to_setting: Button? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_mock_bus)

        MockLocation.init(this)
        initView()
        initData()
    }

    private fun initView(){
        tv_longitude = findViewById(R.id.tv_longitude)
        tv_latitude = findViewById(R.id.tv_latitude)
        btn_to_setting = findViewById(R.id.btn_to_setting)
        btn_to_setting?.setOnClickListener {
            Intent(this, MockLocationActivity::class.java).also {
                startActivity(it)
            }
        }
    }

    private fun initData(){
        val mockLocation = MockLocation.getInstance()
        val location = mockLocation.getLocation()
        android.util.Log.d("BusinessActivity", "location: latitude=${location?.latitude}, longitude=${location?.longitude}")
        tv_longitude?.text = location?.longitude?.toString()
        tv_latitude?.text = location?.latitude?.toString()
    }
}